<!--
  The Top Bar
-->

<div id="topbar-wrapper" class="row justify-content-center topbar-down">
  <div id="topbar" class="col-11 d-flex h-100 align-items-center justify-content-between">
    <span id="breadcrumb">

    {% assign paths = page.url | split: '/' %}

    {% if paths.size == 0 %}
      <!-- index page -->
      <span>{{ 'Posts' }}</span>
    {% else %}

      {% for item in paths %}

        {% if forloop.first %}
          {% unless page.layout == 'post' %}
          <span>
            <a href="{{ '/' | relative_url }}">{{ 'Home' }}</a>
          </span>
          {% endunless %}

        {% elsif forloop.last %}
          <span>{{ page.title }}</span>

        {% else %}
        <span>
          {% assign url = item %}
          {% if item == 'posts' and page.layout == 'post' %}
            {% assign url = '/' %}
          {% endif %}
          <a href="{{ url | relative_url }}">
            {{ item | capitalize }}
          </a>
        </span>

        {% endif %}

      {% endfor %}

    {% endif %}

    </span><!-- endof #breadcrumb -->

    <i id="sidebar-trigger" class="fas fa-bars fa-fw"></i>

    <div id="topbar-title">
      {% if page.layout == 'home' %}
        {{- site.title -}}
      {% elsif page.dynamic_title %}
        {{- page.title -}}
      {% else %}
        {{- page.layout | capitalize -}}
      {% endif %}
    </div>

    <i id="search-trigger" class="fas fa-search fa-fw"></i>
    <span id="search-wrapper" class="align-items-center">
      <i class="fas fa-search fa-fw"></i>
      <input class="form-control" id="search-input" type="search"
        aria-label="search" autocomplete="off" placeholder="{{ site.data.label.search_hint | default: 'Search' }}...">
      <i class="fa fa-times-circle fa-fw" id="search-cleaner"></i>
    </span>
    <span id="search-cancel" >Cancel</span>
  </div>

</div>
